package de.slothsoft.games;

import java.util.HashSet;
import java.util.Set;

public final class Input {

	private final Set<Integer> pressedKeys = new HashSet<>();
	private final Set<Integer> typedKeys = new HashSet<>();

	public boolean isKeyPressed(int pressedKey) {
		return this.pressedKeys.contains(Integer.valueOf(pressedKey));
	}

	void pressedKey(int pressedKey) {
		this.pressedKeys.add(Integer.valueOf(pressedKey));
	}

	void releasedKey(int releasedKey) {
		this.pressedKeys.remove(Integer.valueOf(releasedKey));
	}

	public boolean isKeyTyped(int typedKey) {
		return this.typedKeys.contains(Integer.valueOf(typedKey));
	}

	void typedKey(int typedKey) {
		this.typedKeys.add(Integer.valueOf(typedKey));
	}

	void releaseTypedKeys() {
		this.typedKeys.clear();
	}
}
